package com.anuai.abctest2.Controller;

import com.anuai.abctest2.Configuration.TestCfg;
import com.anuai.abctest2.Configuration.UserinfoCfg;
import com.anuai.abctest2.MessageBus.Sender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test2")
public class TestController {
    @Autowired
    private UserinfoCfg userinfoCfg;

    @Autowired
    private TestCfg testCfg;

    @Autowired
    private Sender sender;

    @RequestMapping("/hi")
    public String hi() {
        return "hi ,i'm ABCloud(test1)";
    }

    @RequestMapping("/hello")
    public String hello() {
        return "hello ,i'm ABCloud(test1)";
    }

    @RequestMapping("/nameFromCfg")
    public String nameFromCfg(){
        return userinfoCfg.getName() + "[ABC-TEST2]";
    }

    @RequestMapping("/nameFromAbcCfg")
    public String nameFromAbcCfg(){
        return testCfg.getName() + "[ABC-TEST2]";
    }

    @RequestMapping("/bus")
    public Boolean bus(){
        sender.send("我是来自 abc-test2 的消息!  你听到了吗？");
        return true;
    }
}
